//
//  NEDAlertView.h
//  MoreCoin
//
//  Created by 林宁宁 on 2019/10/28.
//  Copyright © 2019 MoreCoin. All rights reserved.
//

#import "NEDPopBaseView.h"
#import <NEDCategory/NSMutableAttributedString+NED.h>
#import "UIButton+NEDSet.h"
#import <NEDBase/NEDBaseObject.h>

NS_ASSUME_NONNULL_BEGIN

@class NEDAlertView;
@class NEDAlertLayoutConfig;

typedef void (^ _Nullable NEDAlertButtonClickAction)(NEDAlertView * _Nonnull alertView);

@protocol NEDAlertViewChildrenProtocol <NSObject>

/// 子视图创建视图
- (void)alert_buildContentView;

@optional
- (void)alert_config:(NEDAlertLayoutConfig *)config;

- (void)alert_layoutUpdate;

@end


@interface NEDAlertView : NEDPopBaseView<NEDAlertViewChildrenProtocol>
/// 布局信息
@property (retain, nonatomic, readonly) NEDAlertLayoutConfig * layoutConfig;
/// 点击按钮之后关闭 弹窗 默认YES
@property (assign, nonatomic) BOOL tapButtonToClose;

/// 配置信息 需要设置布局之前
- (void)layoutStyleConfig:(void(^)(NEDAlertLayoutConfig * config))config;
- (void)layoutConfigWithStyle:(NEDAlertLayoutConfig *)style;


+ (void)showConfig:(void (^)(NEDAlertView * _Nonnull alertView))config;

/// 添加顶部标题
- (void)addHeadTitle:(NSString *)title;
- (void)addHeadTitle:(NSString *)title attTitle:(void(^ _Nullable)(NSMutableAttributedString * attTitle))attBlock;
- (void)addHeadAttribute:(void(^ _Nullable)(NSMutableAttributedString * attContent))attBlock;
/// 添加顶部背景图
- (void)addHeadBackgroundImage:(UIImage *)image;
- (void)addHeadBackgroundColor:(UIColor *)color;
- (void)addHeadImage:(UIImage *)image;

/// 添加内容
- (void)addContent:(NSString *)content;
- (void)addContent:(NSString *)content attContent:(void(^ _Nullable)(NSMutableAttributedString * attContent))attBlock;
- (void)addContentAttribute:(void(^ _Nullable)(NSMutableAttributedString * attContent))attBlock;


/// 添加自定义视图 在conent下方 buttons上方 只有一个
- (void)addCustomView:(UIView *)customView;
- (void)addCustomView:(UIView *)customView contentHeight:(CGFloat)contentHeight;


/// 添加选择按钮 做多五个
/// 从左到右 从上到下
- (UIButton *)addBtnTitle:(NSString *)btnTitle action:(NEDAlertButtonClickAction)action;
- (UIButton *)addBtnBlock:(void(^_Nullable)(UIButton * passBtn))btnBlock action:(NEDAlertButtonClickAction)action;

- (UIButton *)addBtnCancel;
- (UIButton *)addBtnCloseTitle:(NSString *)closeTitle;

/// 在按钮上方添加提示
- (void)addHintButtonsTop:(NSString * _Nullable)hint config:(void(^_Nullable)(UILabel * hintLabel))config;
/// 在按钮下方添加提示
- (void)addHintButtonsBottom:(NSString * _Nullable)hint config:(void(^_Nullable)(UILabel * hintLabel))config;

/// 内容
- (UILabel *)alertContentViewText;

@end

@interface NEDAlertView(Add)
/// 默认的弹窗样式 主工程分类重写
- (NEDAlertLayoutConfig * _Nullable)defaultLayoutConfig;

@end

/// alert布局配置
@interface NEDAlertLayoutConfig : NEDBaseObject


/// MARK: Color/font

/// content 背景色 : ned_background
@property (retain, nonatomic) UIColor * contentBackgroundColor;
/// content 背景图
@property (retain, nonatomic) UIImage * _Nullable contentBackgroundImage;

/// 顶部标题颜色：h1
@property (retain, nonatomic) UIColor * colorHeadTitle;
/// 顶部标题字体：pfm 15
@property (retain, nonatomic) UIFont * fontHeadTitle;

/// 内容颜色：h2
@property (retain, nonatomic) UIColor * colorContentText;
/// 内容字体：pf 14
@property (retain, nonatomic) UIFont * fontContentText;

/// 底部按钮字体颜色: h1
@property (retain, nonatomic) UIColor * colorBottomButtonForTitle;
/// 底部按钮按钮背景色: clear
@property (retain, nonatomic) UIColor * colorBottomButtonBackground;
/// 底部按钮字体大小: 14
@property (retain, nonatomic) UIFont * fontBottomButtonForTitle;


/// MARK: Space

/// 标题块距离顶部距离，如果有标题的话 ：10
@property (assign, nonatomic) CGFloat spaceTitleToTop;
/// 标题区到内容区的间距： 8
@property (assign, nonatomic) CGFloat spaceTitleToContent;
/// 内容区到自定义视图的间距： 8
@property (assign, nonatomic) CGFloat spaceContentTextToCustomView;
/// 自定义视图到底部按钮的间距： 8
@property (assign, nonatomic) CGFloat spaceContentViewToButtons;
/// 底部按钮到底部的间距，如果有底部按钮的话： 10
@property (assign, nonatomic) CGFloat spaceButtonsToBottom;

/// 标题左右距离content边界的间距 : 0
@property (assign, nonatomic) CGFloat spaceTitleMargin;
/// 内容左右距离content边界的间距 : 0
@property (assign, nonatomic) CGFloat spaceContentMargin;

/// 底部按钮之间垂直状态的间距 : 10
@property (assign, nonatomic) CGFloat spaceBottomButtonVertical;
/// 底部按钮之间水平状态的间距 : 10
@property (assign, nonatomic) CGFloat spaceBottomButtonHorizontal;
/// 底部按钮左右距离content边界的间距 : spaceBottomButtonHorizontal
@property (assign, nonatomic) CGFloat spaceBottomButtonMargin;


/// MARK: height/width

/// 显示文本区域的最小高度 : 60
@property (assign, nonatomic) CGFloat contentHeightMin;
/// 显示文本区域的最大高度 超过之后 滚动方式：[NEDDeviceInfo s_height]*0.8
@property (assign, nonatomic) CGFloat contentHeightMax;

/// 弹窗的宽度：屏幕宽度的0.8
@property (assign, nonatomic) CGFloat contentWidth;
/// 按钮高度 默认: 40
@property (assign, nonatomic) CGFloat buttonHeight;

/// 如果有设置 则固定该大小 title
@property (assign, nonatomic) CGFloat contentTitleFixHeight;
/// 如果有设置 中间text和customview的区域  则固定该大小 scroll
@property (assign, nonatomic) CGFloat contentScrollFixHeight;
/// 中间text和customview的区域  最大：[NEDDeviceInfo s_height]*0.5
@property (assign, nonatomic) CGFloat contentScrollHeightMax;
/// 中间text和customview的区域  最小：40
@property (assign, nonatomic) CGFloat contentScrollHeightMin;

/// MARK: -

/// 如果按钮的间距为0的时候 是否显示按钮的分割线: NO
@property (assign, nonatomic) BOOL showButtonsSeparationLine;
/// 分割线颜色:ned_separator
@property (retain, nonatomic) UIColor * colorButtonsSeparationLine;
/// 按钮是否需要垂直分布 超过两个之后就变成垂直分布:NO
@property (assign, nonatomic) BOOL buttonLayoutIsVertical;
/// 标题对其方式：center
@property (assign, nonatomic) NSTextAlignment titleAligment;
/// 内容对其方式：center
@property (assign, nonatomic) NSTextAlignment contentTextAligment;

/// 显示按钮的圆角
@property (assign, nonatomic) BOOL showBottomButtonCorner;
/// 显示按钮的圆角大小  如果设置了showBottomButtonCorner：YES 该值未设置 则半圆角
@property (assign, nonatomic) CGFloat bottomButtonCornerRadius;
/// 描边的大小
@property (assign, nonatomic) CGFloat bottomButtonBorderWidth;
/// 描边的颜色
@property (retain, nonatomic) UIColor * bottomButtonBorderColor;

/// contentView的圆角 默认：12
@property (assign, nonatomic) CGFloat contentViewCornerRadius;
/// contentView的描边 默认：0
@property (assign, nonatomic) CGFloat contentViewBorderWidth;
/// contentView的描边色 ned_border
@property (retain, nonatomic) UIColor * contentViewBorderColor;

/// 风格类型
@property (assign, nonatomic) NSInteger styleType;

/// 默认样式
- (void)defaultStyle;
/// 圆角按钮
- (void)cornerBorderButtonStyle;

@end



NS_ASSUME_NONNULL_END
